inhibit: Pass valid arguments when Inhibiting
authorMatthias Clasen <mclasen@redhat.com>
Fri, 21 Aug 2020 21:40:36 +0000 (17:40 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 21 Aug 2020 21:40:36 +0000 (17:40 -0400)
When we pass "" as reason, gnome-session responds
with a "Reason not specified" error. So, send
"Reason not specified" instead. Its true.

gtk/gtkapplication-dbus.c

index d946e0594e1d5cf5e79a9d5be9a5ec97d2323962..812163f8f29f1b31d265783490c676ede0c75b9b 100644 (file)
@@ -25,6 +25,7 @@
 #include "gtkapplicationprivate.h"
 #include "gtksettings.h"
 #include "gtkprivate.h"
+#include "gtkintl.h"
 
 #include "gdk/gdkconstructor.h"
 
@@ -687,12 +688,19 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl         *impl,
 
   if (dbus->sm_proxy)
     {
+      if (reason == NULL)
+        /* Translators: This is the 'reason' given when inhibiting
+         * suspend or screen locking, and the caller hasn't specified
+         * a reason.
+         */
+        reason = _("Reason not specified");
+
       res = g_dbus_proxy_call_sync (dbus->sm_proxy,
                                     "Inhibit",
                                     g_variant_new ("(s@usu)",
                                                    dbus->application_id,
                                                    window ? gtk_application_impl_dbus_get_window_system_id (dbus, window) : g_variant_new_uint32 (0),
-                                                   reason ? reason : "",
+                                                   reason,
                                                    flags),
                                     G_DBUS_CALL_FLAGS_NONE,
                                     G_MAXINT,